翻訳と辞書
Words near each other
・ Ahouakro
・ Ahouannonzoun
・ Ahouanou
・ Ahougnansou (Bouaké)
・ Ahougnanssou (Tiébissou)
・ Ahougnassou-Alahou
・ Ahousaht First Nation
・ Ahousat
・ Ahovan
・ Ahoy
・ Ahoy (greeting)
・ Ahoy Rotterdam
・ Ahoy!
・ Ahoy, Mateys!
・ Ahoyéyé
Aho–Corasick algorithm
・ AHP
・ Ahpeahtone
・ Ahpeatone, Oklahoma
・ AHPL
・ AHQ
・ AHQ Air Defences Eastern Mediterranean
・ Ahq e-Sports Club
・ AHQ Iraq
・ AHQ Levant
・ AHQ Malta
・ Ahqaf al Jabbarat
・ Ahqaf al Jabhiya
・ Ahqaf al Ruzat
・ Ahr


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Aho–Corasick algorithm : ウィキペディア英語版
Aho–Corasick algorithm

In computer science, the Aho–Corasick algorithm is a string searching algorithm invented by Alfred V. Aho and Margaret J. Corasick.〔
〕 It is a kind of dictionary-matching algorithm that locates elements of a finite set of strings (the "dictionary") within an input text. It matches all patterns simultaneously. The complexity of the algorithm is linear in the length of the patterns plus the length of the searched text plus the number of output matches. Note that because all matches are found, there can be a quadratic number of matches if every substring matches (e.g. dictionary = , , , and input string is ).
Informally, the algorithm constructs a finite state machine that resembles a trie with additional links between the various internal nodes. These extra internal links allow fast transitions between failed pattern matches (e.g. a search for in a trie that does not contain , but contains , and thus would fail at the node prefixed by ), to other branches of the trie that share a common prefix (e.g., in the previous case, a branch for might be the best lateral transition). This allows the automaton to transition between pattern matches without the need for backtracking.
When the pattern dictionary is known in advance (e.g. a computer virus database), the construction of the automaton can be performed once off-line and the compiled automaton stored for later use. In this case, its run time is linear in the length of the input plus the number of matched entries.
The Aho–Corasick string matching algorithm formed the basis of the original Unix command fgrep.
==Example==

In this example, we will consider a dictionary consisting of the following words: .
The graph below is the Aho–Corasick data structure constructed from the specified dictionary, with each row in the table representing a node in the trie, with the column path indicating the (unique) sequence of characters from the root to the node.
The data structure has one node for every prefix of every string in the dictionary. So if (bca) is in the dictionary, then there will be nodes for (bca), (bc), (b), and (). If a node is in the dictionary then it is a blue node. Otherwise it is a grey node. There is a black directed "child" arc from each node to a node whose name is found by appending one character. So there is a black arc from (bc) to (bca). There is a blue directed "suffix" arc from each node to the node that is the longest possible strict suffix of it in the graph. For example, for node (caa), its strict suffixes are (aa) and (a) and (). The longest of these that exists in the graph is (a). So there is a blue arc from (caa) to (a). The blue arcs can be computed in linear time by repeatedly traversing the blue arcs of a node's parent until the traversing node has a child matching the character of the target node.
There is a green "dictionary suffix" arc from each node to the next node in the dictionary that can be reached by following blue arcs. For example, there is a green arc from (bca) to (a) because (a) is the first node in the dictionary (i.e. a blue node) that is reached when following the blue arcs to (ca) and then on to (a). The green arcs can be computed in linear time by repeatedly traversing blue arcs until a filled in node is found, and memoizing this information.

At each step, the current node is extended by finding its child,
and if that doesn't exist, finding its suffix's child, and if
that doesn't work, finding its suffix's suffix's child, and so on, finally
ending in the root node if nothing's seen before.
When the algorithm reaches a node, it outputs all the dictionary
entries that end at the current character position in the input text. This is done
by printing every node reached by following the dictionary suffix links, starting
from that node, and continuing until it reaches a node with no dictionary suffix link.
In addition, the node itself is printed, if it is a dictionary entry.
Execution on input string yields the following steps:

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Aho–Corasick algorithm」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.